
ALTER  proc sp_insert_shipped_order_line_item
@customer_shipping_id int
AS
begin
	declare @csl_cursor CURSOR
	declare @temp_line_item_id int
	declare @temp_qty_shipped int
	declare @temp_shipped_date datetime

	set @csl_cursor = CURSOR FOR
	select LineItem_ID, CSLIT_Qty_Shipped, CSLIT_Shipped_Date from Customer_shipping_line_Item_Table where CustomerShipping_ID = @customer_shipping_id

	open @csl_cursor
		fetch next from @csl_cursor into @temp_line_item_id, @temp_qty_shipped, @temp_shipped_date
		while @@fetch_status = 0
		begin
			insert into Customer_Shipped_Order_Lineitem(LineItem_ID, SalesOrder_ID, CSOL_Line_Item_No, Product_ID, CSOL_Qty, CSOL_Unit_Cost, CSOL_Amount, CSOL_Requested_Date, CSOL_Booking_Date, CSOL_Sugg_Schedule_Date_With_Substitutables, CSOL_Sugg_Schedule_Date_Without_Substitutables, CSOL_Schedule_Date, CSOL_Revised_Date, CSOL_Shipped_Date, Timestamp)
			select @temp_line_item_id, SalesOrder_ID, COOL_Line_Item_No, Product_ID, @temp_qty_shipped, COOL_Unit_Cost, COOL_Amount, COOL_Requested_Date, COOL_Booking_Date, COOL_Sugg_Schedule_Date_With_Substitutables, COOL_Sugg_Schedule_Date_Without_Substitutables, COOL_Schedule_Date, COOL_Revised_Date, @temp_shipped_date, current_timestamp from Customer_Open_Order_Lineitem where LineItem_ID = @temp_line_item_id

			fetch next from @csl_cursor into @temp_line_item_id, @temp_qty_shipped, @temp_shipped_date
		end
	close @csl_cursor
	deallocate @csl_cursor
end
